﻿using System;
using Pansoft.HIME.Base.Interfaces.Repositories;
using Pansoft.HIME.Repository.Repositories;

namespace Pansoft.HIME.Repository
{
    public class RepositoriesFactory
    {
        /// <summary>“组织”相关数据管理器
        /// </summary>
        public IOrganizationRepository OrganizationRepository { get; set; }

        /// <summary>“权限”相关数据管理器
        /// </summary>
        public IAuthorityRepository AuthorityRepository { get; set; }

        /// <summary>“明细报表”相关数据管理器
        /// </summary>
        public ITransactionRepository TransactionRepository { get; set; }

        /// <summary>初始化
        /// </summary>
        public void Initiate()
        {
            OrganizationRepository = new OrganizationRepository();
            AuthorityRepository = new AuthorityRepository();
            TransactionRepository = new TransactionRepository();
        }

        #region 单件实例

        private static readonly Lazy<RepositoriesFactory> _Instance = new Lazy<RepositoriesFactory>(() => new RepositoriesFactory());

        private RepositoriesFactory()
        {
            Initiate();
        }

        /// <summary> 获得一个本类型的单件实例.
        /// </summary>
        /// <value>The instance.</value>
        public static RepositoriesFactory Instance
        {
            get { return _Instance.Value; }
        }

        #endregion
    }
}